<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="language" value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}" scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="properties.text" />
<title><fmt:message key="users" /></title>
<link rel="stylesheet" type="text/css" href="/jt-hr-WEB/css/styles.css">
<script type="text/javascript" src="user.js"></script>
</head>
<body onload="sendReq()">
	<form >
            <select id="language" name="language" onchange="submit()">
                <option value="en" ${language == 'en' ? 'selected' : ''}>English</option>
                <option value="de" ${language == 'de' ? 'selected' : ''}>Deutsch</option>
                <option value="ro" ${language == 'ro' ? 'selected' : ''}>Romana</option>
            </select>
    </form>
 <div id="header">
	    <div id="img">
        	<img class="center" src="/jt-hr-WEB/img/msg_header.jpg" height="100px" width="500px"/>    
    		<jsp:include page="/SharedPages/SharedPage.jsp"></jsp:include>
    	</div>
    </div>
    
<div class="content" style="width: 75%;margin: 0 auto; border: solid 3px #E6E1E1;" >
	  <h3 align="center"><fmt:message key="activusers" /></h3>

	<%@ include file="userSearch.jsp" %>

<jsp:useBean id="userList" class="java.util.Vector<User>" scope="session"/>
<jsp:useBean id="operationIsSuccesful" class="java.lang.String" scope="session"/>
<jsp:useBean id="indexUserList" class="java.lang.Integer" scope="session"/>
<jsp:setProperty name="userList" property="*"/> 

<jsp:setProperty name="userList" property="*"/> 
<jsp:setProperty name="operationIsSuccesful" property="*" />
 <%

       if (request.getSession().getAttribute("savedUserType").equals("Director General")){

        %>

      <a href="/jt-hr-WEB/directorGeneralPages/directorGeneralPage.jsp" id="backbutton"><fmt:message key="back" /></a>

      <%}
		%>
<%@ page import="entityJPA.*" %>
<%@ page import="java.util.Vector" %>
<%@ include file="userNavigation.jsp" %>



<TABLE BORDER=2 class="infoTable" align="center">
<TR>
<TH><fmt:message key="username" /></TH>
<TH><fmt:message key="firstname" /></TH>
<TH><fmt:message key="lastname" /></TH>
<TH><fmt:message key="homenumber" /></TH>
<TH><fmt:message key="cellnumber" /></TH>
<TH><fmt:message key="email" /></TH>
<TH><fmt:message key="rank" /></TH>
<TH><fmt:message key="description" /></TH>
<TH><fmt:message key="type" /></TH>
</TR>
<%

  for (User u: userList) {
        %>
        <tr onclick="populateFields(this);" style="cursor:pointer">
        <TD style="display:none;"><%=u.getIdUser() %></TD>
        <TD><%=u.getUsername() %></TD>
        <TD><%= u.getFirstName() %></TD>
        <TD><%= u.getLastName() %></TD>
        <TD><%= u.getHomeNumber() %></TD>
        <TD><%= u.getCellNumber() %></TD>
        <TD><%= u.getEmail() %></TD>
        <TD><%= u.getRank() %></TD>
        <TD><%= u.getDescription() %></TD>
        <TD><%= u.getUsertype().getTitle() %></TD>
        </TR>
        <%
    }
    
%>



</TABLE>

<div align="center"  style="display:block;
	margin:0 auto" >
	-<%=" " +(indexUserList / 4 + 1)+ " "%>-
</div>
<br>
<div class="alert-box success" id="succes" style="display:none;margin-left:5%"><span ><fmt:message key="succes" />:</span><fmt:message key="succesm" /></div>
<br>

<%
	if(operationIsSuccesful=="yes"){
		%>
		<script>
			document.getElementById("succes").style.display='inline';
		</script>
		<% 
	}
 %>
		<%@ include file="userCRUD.jsp" %>
</div>
<script>
	var lang='<c:out value="${language}"/>';
	select=document.getElementById("language");
	if(lang=="de_DE"||lang=="de"){
		select.options[1].defaultSelected=true;
	}
	else if(lang=="ro_RO"||lang=="ro"){
		select.options[2].defaultSelected=true;
	}
	else {
		select.options[0].defaultSelected=true;
	}

	
</script>
</body>
</html>

